<%@ page language="java" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<base href="<%=basePath%>">

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>User Login </title>
	<link rel="stylesheet" type="text/css" href="./jquery-easyui-1.2.5/themes/default/easyui.css">
	<link rel="stylesheet" type="text/css" href="./jquery-easyui-1.2.5/themes/icon.css">
	<link rel="stylesheet" type="text/css" href="./jquery-easyui-1.2.5/demo/demo.css">
	<script type="text/javascript" src="./jquery-easyui-1.2.5/jquery-1.7.1.min.js"></script>
	<script type="text/javascript" src="./jquery-easyui-1.2.5/jquery.easyui.min.js"></script>
	<script>	
		$(function(){
			$('#w').window({
				title: '网站管理系统',
				width: 400,
				height: 220,
				modal: true,
				shadow: false,
				closed: false,
				minimizable: false,
				maximizable: false,
				resizable: false
			});
		});

		function submit(){
			var userNameValidatre = $('#userName').validatebox("isValid");
			var userPasswordValidatre = $('#userPassword').validatebox("isValid");
			var userVerificationCodeValidatre = $('#userVerificationCode').validatebox("isValid");
			
			if(userNameValidatre && userPasswordValidatre && userVerificationCodeValidatre){
				$('form').submit();
			}else{
				$('#login_fail').css("display","none");
				$('#tipUL').css("display","block");
				return;
			}
		}
		
		function reset(){
				$('form').form('clear');
		}
		
		function changeImg(){
			 $("#authCode").attr("src","admin/authCode.action?d="+new Date().valueOf());       

		}
	</script>
</head>
<body style="height:100%;width:100%;overflow:hidden;border:none;" >
	<div id="w" class="easyui-window" title="My Window" iconCls="icon-edit" style="width:400px;height:215px;padding:5px;">
		<div class="easyui-layout" fit="true">
			<div region="center" border="false" style="padding:14px;background:#fff;border:1px solid #ccc;">
				<div>
					<form action="<%=basePath%>admin/login.action" method="post" style="margin-bottom: 0px;">
						<div style="margin-left: 60px;margin-top: 23px;">
								<span>用户：&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>
								<input id="userName" name="user.userid" class="easyui-validatebox" size="20" maxlength="16" required="true" validType="length[3,16]" invalidMessage="帐号长度必须在3和16位之间" missingMessage="请输入用户名"/>
						</div>
						<div style="margin-left: 60px;margin-top: 5px;">
								<span>密码：&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>
								<input id="userPassword" name="password.password" class="easyui-validatebox" type="password" size="20" maxlength="16" required="true" validType="length[3,16]" invalidMessage="密码长度必须在3和16位之间" missingMessage="请输入密码"/>
								<img src="./resources/images/luck.gif" width="19" height="18">
						</div>
						<div style="margin-left: 60px;margin-top: 5px;">
								<span>验证码：&nbsp;&nbsp;&nbsp;</span>
								<input id="userVerificationCode" name="userVerificationCode" class="easyui-validatebox"  size="2" required="true"  validType="length[1,4]" maxlength="4"/>	
								<img alt="验证码" src="admin/authCode.action" id="authCode" onclick="changeImg();">
								<a href="#" style="margin: 2px;" onclick="changeImg();">看不清,换一张!</a>						
						</div>
						<div>
							&nbsp;
							&nbsp;
							&nbsp;
						</div>
						<ul id="tipUL" class="errorMessage" style="color: red;position:absolute;margin-top: 2px;margin-left: 120px;display: none;margin-bottom: 0px;">
	            			<li>
	            				<span>输入不正确,请按提示重新输入。</span>
	            			</li>
            			</ul>
						<s:actionerror key="login.fail" cssStyle="color: red;position:absolute;margin-left: 120px;margin-top: 2px;margin-bottom: 0px;"/>
					</form>
				</div>
			</div>
			<div region="south" border="false" style="text-align:right;padding:5px;margin-top: 0px;">
				<a class="easyui-linkbutton" iconCls="icon-ok" href="javascript:void(0)" onclick="submit();">登录</a>
				<a class="easyui-linkbutton" iconCls="icon-cancel" href="javascript:void(0)" onclick="reset();">重置</a>
			</div>
		</div>
	</div>
</body>
</html>
